<template>
  <div class="other-screen-page index-4-1">
    <div class="middleBg">
      <!-- <div class="middleBgLeft"></div> -->
      <div class="middleBgMid">

        <!-- 重新计算按钮 -->
<!--        <div class="recalculate-btn" @click="recalculateData">-->
<!--          重新计算-->
<!--        </div>-->

        <div class="content1">
          <div class="content">
            <!-- <div class="contentTop">
              <div class="left"></div>
              <div class="middle">
               <div class="title">化石燃料燃烧碳排放</div>
              </div>
              <div class="right"></div>
            </div> -->
            <div class="contentBottom">
              <div class="left"></div>
              <div class="middle">
                <div class="chart gdztzb" id="gdztzb"></div>
                <!-- 结果框 -->
                <div class="result-box">化石燃料燃烧碳排放:{{ gdztzbTotal }}tCO₂</div>

              </div>
              <div class="right"></div>
            </div>
          </div>
          <div class="content">
            <!-- <div class="contentTop">
              <div class="left"></div>
              <div class="middle">
               <div class="title">购入使用电力热力产生碳排放</div>
              </div>
              <div class="right"></div>
            </div> -->
            <div class="contentBottom">
              <div class="left"></div>
              <div class="middle">
                <div class="chart gdsbzb" id="gdsbzb"></div>
                <!-- 结果框 -->
                <div class="result-box">购入使用电力热力产生碳排放:{{ gdsbzbTotal }}tCO₂</div>
              </div>
              <div class="right"></div>
            </div>
          </div>
          <div class="content">
            <!-- <div class="contentTop">
              <div class="left"></div>
              <div class="middle">
               <div class="title">过程碳排放</div>
              </div>
              <div class="right"></div>
            </div> -->
            <div class="contentBottom">
              <div class="left"></div>
              <div class="middle" >
                <div class="chart gdslqs" id="gdslqs"></div>
                <!-- 结果框 -->
                <div class="result-box">过程碳排放:{{ gdslqsTotal }}tCO₂</div>
              </div>
              <div class="right"></div>
            </div>
          </div>
        </div>

        <div class="content2">
          <div class="content">
            <!-- <div class="contentTop">
              <div class="left"></div>
              <div class="middle">
               <div class="title">碳交易</div>
              </div>
              <div class="right"></div>
            </div> -->
            <div class="contentBottom">
              <div class="left"></div>
              <div class="middle">
                <div class="chart yjdjgdtj" id="yjdjgdtj"></div>
                <!-- 结果框 -->
                <div class="result-box">碳交易:{{ yjdjgdtjTotal }}tCO₂</div>
              </div>
              <div class="right"></div>
            </div>
          </div>
          <div class="content">
            <!-- <div class="contentTop">
              <div class="left"></div>
              <div class="middle">
               <div class="title">碳抵消</div>
              </div>
              <div class="right"></div>
            </div> -->
            <div class="contentBottom">
              <div class="left"></div>
              <div class="middle">
                <div class="chart yjlxgdtj" id="yjlxgdtj"></div>
                <!-- 结果框 -->
                <div class="result-box">碳抵消:{{ yjlxgdtjTotal }}tCO₂</div>
              </div>
              <div class="right"></div>
            </div>
          </div>
          <div class="content">
            <!-- <div class="contentTop">
              <div class="left"></div>
              <div class="middle">
               <div class="title">工单类型统计</div>
              </div>
              <div class="right"></div>
            </div> -->
            <div class="contentBottom">
              <div class="left"></div>
              <div class="middle">
                <div class="chart gdlxtj" id="gdlxtj"></div>
                <div class="result-box">碳排放总量:{{ carbonTotal }}tCO₂</div>
              </div>
              <div class="right"></div>
            </div>
          </div>
        </div>

      </div>
      <div class="middleBgRight"></div>
    </div>
  </div>
</template>

<script>
import {
  getcalRecyclingCarbon,
  getcalHeatEmission,
  getcalLiquidFuel,
  getcalNitreEmission,
  getcalSolidFuel,
  getcalSulfurEmission,
  getcalWeldHeatEmission,
  getcalBlastEmission,
  getcalculateCarbonVolume,
  getcalculateCcerVolume,
  getcalDirectRelease,
  getcalEleEmission,
  getcalGasFuel,
  getcalGreenCarbon,
  getcalGreenCertificate
} from "@/api/eleLoad/project";
import PieChart from "./components/PieChart";
import option from "./components/option";

export default {
  components: {
    PieChart
  },
  data() {
    return {
      echarts: [],
      xData: [],
      dateRange: [],
      startTime: '',
      endTime: '',
      projectId: '',

      gdslqsChart: null,
      gdztzbChart: null,
      gdsbzbChart: null,
      gcdyqxChart: null,
      yjdjgdtjChart: null,
      yjlxgdtjChart: null,
      gdlxtjChart: null,

      gdztzbTotal: 0,
      gdsbzbTotal: 0,
      gdslqsTotal: 0,
      yjdjgdtjTotal: 0,
      yjlxgdtjTotal: 0,
    };
  },
  computed: {
    carbonTotal() {
      // 确保所有值都是数字
      const gdztzbTotal = parseFloat(this.gdztzbTotal) || 0;
      const gdsbzbTotal = parseFloat(this.gdsbzbTotal) || 0;
      const gdslqsTotal = parseFloat(this.gdslqsTotal) || 0;
      const yjdjgdtjTotal = parseFloat(this.yjdjgdtjTotal) || 0;
      const yjlxgdtjTotal = parseFloat(this.yjlxgdtjTotal) || 0;

      const total = gdztzbTotal + gdsbzbTotal + gdslqsTotal - yjdjgdtjTotal - yjlxgdtjTotal;
      this.$nextTick(() => {
        this.createGdlxtjChart(gdztzbTotal, gdsbzbTotal, gdslqsTotal, yjdjgdtjTotal, yjlxgdtjTotal);
      });
      return total.toFixed(2);  // 保留两位小数
    }
  },
  created() {
    this.projectId = this.$store.state.projectDict.projectId;
  },
  mounted() {
    this.selectData();
  },
  methods: {
    selectData() {
      let params = {};
      if (this.dateRange == null || this.dateRange.length < 2) {
        // return
      } else {
        params = {
          startTime: this.dateRange[0],
          endTime: this.dateRange[1],
        };
      }
      this.getGdztzbData(params);
      this.getGdsbzbData(params);
      this.getGdslqsData(params);
      this.getYjdjgdtjData(params);
      this.getYjlxgdtjData(params);

      // 调用所有计算接口
      this.getGasFuelData({projectId: this.projectId});       // 气体燃料计算
      this.getLiquidFuelData({projectId: this.projectId});    // 液体燃料计算
      this.getSolidFuelData({projectId: this.projectId});     // 固体燃料计算
      this.getHeatEmissionData({projectId: this.projectId});  // 热力排放计算
      this.getNitreEmissionData({projectId: this.projectId}); // 脱硝排放计算
      this.getRecyclingCarbonData({projectId: this.projectId}); // 回收利用碳汇计算
      this.getSulfurEmissionData({projectId: this.projectId}); // 脱硫排放计算
      this.getWeldHeatEmissionData({projectId: this.projectId}); // 切焊加热计算
      this.getBlastEmissionData({projectId: this.projectId}); // 爆破过程排放计算
      this.getCalculateCcerVolumeData({projectId: this.projectId}); // 碳交易ccer计算
      this.getCalculateCarbonVolumeData({projectId: this.projectId}); // 碳交易计算
      this.getDirectReleaseData({projectId: this.projectId}); // 直接释放计算
      this.getEleEmissionData({projectId: this.projectId});   // 电力排放计算
      this.getGreenCarbonData({projectId: this.projectId});   // 绿化碳汇计算
      this.getGreenCertificateData({projectId: this.projectId}); // 购买绿证碳汇计算
    },

    // 重新计算数据的方法
    recalculateData() {
      this.selectData();
    },

    // 化石燃料燃烧碳排放
    getGdztzbData(params) {
      let that = this;
      that.createGdztzbChart();
    },
    createGdztzbChart(solid, liquid, gas) {
      let _chart;
      if (this['gdztzbChart']) {
        _chart = this['gdztzbChart'];
      } else {
        let chart = document.getElementById('gdztzb');
        if (chart == null) {
          return;
        }
        _chart = this.$echarts.init(chart);
      }

      let ops = option['gdztzb'];

      // 确保值是数字类型
      solid = solid ? parseFloat(solid) : 0;
      liquid = liquid ? parseFloat(liquid) : 0;
      gas = gas ? parseFloat(gas) : 0;

      ops.series[0]['data'][0]['value'] = solid;
      ops.series[0]['data'][0]['name'] = `固体燃料 (${solid})`;

      ops.series[0]['data'][1]['value'] = liquid;
      ops.series[0]['data'][1]['name'] = `液体燃料 (${liquid})`;

      ops.series[0]['data'][2]['value'] = gas;
      ops.series[0]['data'][2]['name'] = `气体燃料 (${gas})`;

      // 更新图表数据
      _chart.setOption(ops);
      this['gdztzbChart'] = _chart;

      // 计算总和并保存到数据中 - 化石燃料燃烧碳排放
      this.gdztzbTotal = (solid + liquid + gas).toFixed(2);
    },


    // 购入使用电力热力产生碳排放
    getGdsbzbData(params) {
      let that = this;
      that.createGdsbzbChart();
    },
    createGdsbzbChart(ele, heat) {
      let _chart;
      if (this['gdsbzbChart']) {
        _chart = this['gdsbzbChart'];
      } else {
        let chart = document.getElementById('gdsbzb');
        if (chart == null) {
          return;
        }
        _chart = this.$echarts.init(chart);
      }
      let ops = option['gdsbzb'];

      // 确保值是数字类型
      // ele = ele ? parseFloat(ele) : (ops.series[0]['data'][0]['value'] || 0);
      // heat = heat ? parseFloat(heat) : (ops.series[0]['data'][1]['value'] || 0);
      ele = ele ? parseFloat(ele) : 0;
      heat = heat ? parseFloat(heat) : 0;


      ops.series[0]['data'][0]['value'] = ele;
      ops.series[0]['data'][0]['name'] = `电力 (${ele})`;

      ops.series[0]['data'][1]['value'] = heat;
      ops.series[0]['data'][1]['name'] = `热力 (${heat})`;

      _chart.setOption(ops);
      this['gdsbzbChart'] = _chart;

      // 计算总和并保存到数据中 - 购入使用电力热力产生碳排放
      this.gdsbzbTotal = (ele + heat).toFixed(2);
    },

    // 过程碳排放
    getGdslqsData(params) {
      let that = this;
      that.createGdslqsChart();
    },
    createGdslqsChart(tl, tx, zy, qhjr, zjsf) {
      let _chart;
      if (this['gdslqsChart']) {
        _chart = this['gdslqsChart'];
      } else {
        let chart = document.getElementById('gdslqs');
        if (chart == null) {
          return;
        }
        _chart = this.$echarts.init(chart);
      }
      let ops = option['gdslqs'];

      // 确保值是数字类型
      tl = tl ? parseFloat(tl) : 0;
      tx = tx ? parseFloat(tx) : 0;
      zy = isNaN(zy) ? 0 : parseFloat(zy);
      qhjr = qhjr ? parseFloat(qhjr) : 0;
      zjsf = zjsf ? parseFloat(zjsf) : 0;

      ops.series[0]['data'][0]['value'] = tl;
      ops.series[0]['data'][0]['name'] = `脱硫 (${tl})`;

      ops.series[0]['data'][1]['value'] = tx;
      ops.series[0]['data'][1]['name'] = `脱硝 (${tx})`;

      ops.series[0]['data'][2]['value'] = zy;
      ops.series[0]['data'][2]['name'] = `炸药 (${zy})`;

      ops.series[0]['data'][3]['value'] = qhjr;
      ops.series[0]['data'][3]['name'] = `切焊加热 (${qhjr})`;

      ops.series[0]['data'][4]['value'] = zjsf;
      ops.series[0]['data'][4]['name'] = `直接释放 (${zjsf})`;

      _chart.setOption(ops);
      this['gdslqsChart'] = _chart;

      // 计算总和并保存到数据中 - 过程碳排放
      this.gdslqsTotal = (tl + tx + zy + qhjr + zjsf).toFixed(2);
    },


    // 碳交易
    getYjdjgdtjData(params) {
      let that = this;
      that.createYjdjgdtjChart();
    },
    createYjdjgdtjChart(ccer, thp) {
      let _chart;
      if (this['yjdjgdtjChart']) {
        _chart = this['yjdjgdtjChart'];
      } else {
        let chart = document.getElementById('yjdjgdtj');
        if (chart == null) {
          return;
        }
        _chart = this.$echarts.init(chart);
      }
      let ops = option['yjdjgdtj'];

      // 确保值是数字类型
      ccer = ccer ? parseFloat(ccer) : 0;
      thp = thp ? parseFloat(thp) : 0;


      ops.series[0]['data'][0]['value'] = ccer;
      ops.series[0]['data'][0]['name'] = `ccer (${ccer})`;

      ops.series[0]['data'][1]['value'] = thp;
      ops.series[0]['data'][1]['name'] = `碳汇普 (${thp})`;

      _chart.setOption(ops);
      this['yjdjgdtjChart'] = _chart;

      // 计算总和
      this.yjdjgdtjTotal = (ccer + thp).toFixed(2);
    },


    // 碳抵消
    getYjlxgdtjData(params) {
      let that = this;
      that.createYjlxgdtjChart();
    },
    createYjlxgdtjChart(lh, hsly, lz) {
      let _chart;
      if (this['yjlxgdtjChart']) {
        _chart = this['yjlxgdtjChart'];
      } else {
        let chart = document.getElementById('yjlxgdtj');
        if (chart == null) {
          return;
        }
        _chart = this.$echarts.init(chart);
      }
      let ops = option['yjlxgdtj'];

      // 确保值是数字类型
      lh = lh ? parseFloat(lh) : (ops.series[0]['data'][0]['value'] || 0);
      hsly = hsly ? parseFloat(hsly) : (ops.series[0]['data'][1]['value'] || 0);
      lz = lz ? parseFloat(lz) : (ops.series[0]['data'][2]['value'] || 0);

      ops.series[0]['data'][0]['value'] = lh;
      ops.series[0]['data'][0]['name'] = `绿化 (${lh})`;

      ops.series[0]['data'][1]['value'] = hsly;
      ops.series[0]['data'][1]['name'] = `回收利用 (${hsly})`;

      ops.series[0]['data'][2]['value'] = lz;
      ops.series[0]['data'][2]['name'] = `绿证 (${lz})`;

      _chart.setOption(ops);
      this['yjlxgdtjChart'] = _chart;

      // 计算总和并保存到数据中 - 碳抵消
      this.yjlxgdtjTotal = (lh + hsly + lz).toFixed(2);
    },


    //碳排放总量
    createGdlxtjChart(gdztzbTotal,gdsbzbTotal,gdslqsTotal,yjdjgdtjTotal,yjlxgdtjTotal) {
      let _chart;
      if (this['gdlxtjChart']) {
        _chart = this['gdlxtjChart'];
      } else {
        let chart = document.getElementById('gdlxtj');
        if (chart == null) {
          return;
        }
        _chart = this.$echarts.init(chart);
      }
      let ops = option['gdlxtj'];

      // 确保值是数字类型
      gdztzbTotal = gdztzbTotal ? parseFloat(gdztzbTotal) : 0;
      gdsbzbTotal = gdsbzbTotal ? parseFloat(gdsbzbTotal) : 0;
      gdslqsTotal = gdslqsTotal ? parseFloat(gdslqsTotal) : 0;
      yjdjgdtjTotal = yjdjgdtjTotal ? parseFloat(yjdjgdtjTotal) : 0;
      yjlxgdtjTotal = yjlxgdtjTotal ? parseFloat(yjlxgdtjTotal) : 0;

      // 更新图表数据
      ops.series[0]['data'] = [
        {
          name: `化石燃料 (${gdztzbTotal})`,
          value: gdztzbTotal,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#008eec"}, {offset: 1, color: "#008EEC"}],
              x: 0, y: 0, x2: 0, y2: 1, type: "linear", global: false
            }
          }
        },
        {
          name: `电力热力 (${gdsbzbTotal})`,
          value: gdsbzbTotal,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#5c63e3"}, {offset: 1, color: "#5c82e3"}],
              x: 0, y: 0, x2: 0, y2: 1, type: "linear", global: false
            }
          }
        },
        {
          name: `过程碳排放 (${gdslqsTotal})`,
          value: gdslqsTotal,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#d5ca00"}, {offset: 1, color: "#d5ca00"}],
              x: 0, y: 0, x2: 0, y2: 1, type: "linear", global: false
            }
          }
        },
        {
          name: `碳交易 (${yjdjgdtjTotal})`,
          value: yjdjgdtjTotal,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "#e3675c"}, {offset: 1, color: "#e3675c"}],
              x: 0, y: 0, x2: 0, y2: 1, type: "linear", global: false
            }
          }
        },
        {
          name: `碳抵消 (${yjlxgdtjTotal})`,
          value: yjlxgdtjTotal,
          itemStyle: {
            color: {
              colorStops: [{offset: 0, color: "rgba(162,227,92,0.85)"}, {offset: 1, color: "rgba(162,227,92,0.85)"}],
              x: 0, y: 0, x2: 0, y2: 1, type: "linear", global: false
            }
          }
        }
      ];

      _chart.setOption(ops);
      this['gdlxtjChart'] = _chart;
    },



    // 固体燃料计算
    getSolidFuelData(params) {
      getcalSolidFuel(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新图表数据
          this.createGdztzbChart(
            response.data, // 使用接口返回的固体燃料数据
            this.gdztzbChart?.getOption().series[0].data[1].value, // 使用现有液体燃料数据
            this.gdztzbChart?.getOption().series[0].data[2].value // 使用现有气体燃料数据
          );
        }
      }).catch(error => {
        console.error('获取固体燃料计算数据失败:', error);
      });
    },

// 液体燃料计算
    getLiquidFuelData(params) {
      getcalLiquidFuel(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新图表数据
          this.createGdztzbChart(
            this.gdztzbChart?.getOption().series[0].data[0].value, // 使用现有固体燃料数据
            response.data, // 使用接口返回的液体燃料数据
            this.gdztzbChart?.getOption().series[0].data[2].value // 使用现有气体燃料数据
          );
        }
      }).catch(error => {
        console.error('获取液体燃料计算数据失败:', error);
      });
    },

// 气体燃料计算
    getGasFuelData(params) {
      getcalGasFuel(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新图表数据
          this.createGdztzbChart(
            this.gdztzbChart?.getOption().series[0].data[0].value, // 使用现有固体燃料数据
            this.gdztzbChart?.getOption().series[0].data[1].value, // 使用现有液体燃料数据
            response.data // 使用接口返回的气体燃料数据
          );
        }
      }).catch(error => {
        console.error('获取气体燃料计算数据失败:', error);
      });
    },


    // 电力排放计算
    getEleEmissionData(params) {
      getcalEleEmission(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新电力排放图表数据
          this.createGdsbzbChart(
            response.data,
            this.gdsbzbChart?.getOption().series[0].data[1].value)
        }
      }).catch(error => {
        console.error('获取电力排放计算数据失败:', error);
      });
    },


// 热力排放计算
    getHeatEmissionData(params) {
      getcalHeatEmission(params).then(response => {
        // 处理响应数据
        // 可以根据需要更新图表或其他数据
        if (response && response.data !== null) {
          // 更新电力排放图表数据，确保正确传递ele和heat参数
          this.createGdsbzbChart(
            this.gdsbzbChart?.getOption().series[0].data[0].value,
            response.data
          );
        }
      }).catch(error => {
        console.error('获取热力排放计算数据失败:', error);
      });
    },

    // 脱硫排放计算
    getSulfurEmissionData(params) {
      getcalSulfurEmission(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新图表数据
          this.createGdslqsChart(
            response.data,
            this.gdslqsChart?.getOption().series[0].data[1].value,
            this.gdslqsChart?.getOption().series[0].data[2].value,
            this.gdslqsChart?.getOption().series[0].data[3].value,
            this.gdslqsChart?.getOption().series[0].data[4].value,
          );
        }
      }).catch(error => {
        console.error('获取脱硫排放计算数据失败:', error);
      });
    },


    // 脱硝排放计算
    getNitreEmissionData(params) {
      getcalNitreEmission(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新图表数据
          this.createGdslqsChart(
            this.gdslqsChart?.getOption().series[0].data[0].value,
            response.data,
            this.gdslqsChart?.getOption().series[0].data[2].value,
            this.gdslqsChart?.getOption().series[0].data[3].value,
            this.gdslqsChart?.getOption().series[0].data[4].value,
          );
        }
      }).catch(error => {
        console.error('获取脱硝排放计算数据失败:', error);
      });
    },


    // 爆破过程排放计算
    getBlastEmissionData(params) {
      getcalBlastEmission(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新图表数据
          this.createGdslqsChart(

            this.gdslqsChart?.getOption().series[0].data[0].value,
            this.gdslqsChart?.getOption().series[0].data[1].value,
            response.data,
            this.gdslqsChart?.getOption().series[0].data[3].value,
            this.gdslqsChart?.getOption().series[0].data[4].value,
          );
        }
      }).catch(error => {
        console.error('获取爆破过程排放计算数据失败:', error);
      });
    },

    // 切焊加热计算
    getWeldHeatEmissionData(params) {
      getcalWeldHeatEmission(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新图表数据
          this.createGdslqsChart(

            this.gdslqsChart?.getOption().series[0].data[0].value,
            this.gdslqsChart?.getOption().series[0].data[1].value,
            this.gdslqsChart?.getOption().series[0].data[2].value,
            response.data,
            this.gdslqsChart?.getOption().series[0].data[4].value,
          );
        }
      }).catch(error => {
        console.error('获取切焊加热计算数据失败:', error);
      });
    },

    // 直接释放计算
    getDirectReleaseData(params) {
      getcalDirectRelease(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新图表数据
          this.createGdslqsChart(
            this.gdslqsChart?.getOption().series[0].data[0].value,
            this.gdslqsChart?.getOption().series[0].data[1].value,
            this.gdslqsChart?.getOption().series[0].data[2].value,
            this.gdslqsChart?.getOption().series[0].data[3].value,
            response.data,
          );
        }
      }).catch(error => {
        console.error('获取直接释放计算数据失败:', error);
      });
    },

     // ccer
    getCalculateCcerVolumeData(params) {
      getcalculateCcerVolume(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新ccer图表数据
          this.createYjdjgdtjChart(
            response.data,
            this.yjdjgdtjChart?.getOption().series[0].data[1].value,
          );
        }
      }).catch(error => {
        console.error('获取碳交易ccer计算数据失败:', error);
      });
    },


    // 碳交易
    getCalculateCarbonVolumeData(params) {
      getcalculateCarbonVolume(params).then(response => {
        // 处理响应数据
        if (response && response.data !== null) {
          // 更新电力排放图表数据
          this.createYjdjgdtjChart(
            this.yjdjgdtjChart?.getOption().series[0].data[0].value,
            response.data,
          );
        }
      }).catch(error => {
        console.error('获取碳交易计算数据失败:', error);
      });
    },



    // 绿化碳汇计算-
    getGreenCarbonData(params) {
      getcalGreenCarbon(params).then(response => {
        // 处理响应数据
        if (response && response.data) {
          // 更新绿化碳汇图表数据
          this.createYjlxgdtjChart(
            response.data,
            this.yjlxgdtjChart?.getOption().series[0].data[1].value,
            this.yjlxgdtjChart?.getOption().series[0].data[2].value
          );
        }
      }).catch(error => {
        console.error('获取绿化碳汇计算数据失败:', error);
      });
    },

    // 回收利用碳汇计算
    getRecyclingCarbonData(params) {
      getcalRecyclingCarbon(params).then(response => {
        // 处理响应数据
        if (response && response.data) {
          // 更新绿化碳汇图表数据
          this.createYjlxgdtjChart(
            this.yjlxgdtjChart?.getOption().series[0].data[0].value,
            response.data,
            this.yjlxgdtjChart?.getOption().series[0].data[1].value
          );
        }
      }).catch(error => {
        console.error('获取回收利用碳汇计算数据失败:', error);
      });
    },


    // 购买绿证碳汇计算
    getGreenCertificateData(params) {
      getcalGreenCertificate(params).then(response => {
        // 处理响应数据
        if (response && response.data) {
          // 更新购买绿证碳汇图表数据
          this.createYjlxgdtjChart(
            this.yjlxgdtjChart?.getOption().series[0].data[0].value,
            this.yjlxgdtjChart?.getOption().series[0].data[1].value,
            response.data,
          );
        }
      }).catch(error => {
        console.error('获取购买绿证碳汇计算数据失败:', error);
      });
    },
  },
};
</script>

<style lang="scss" scoped>
@import './components/index-4-1';
.recalculate-btn {
  position: absolute;
  top: 50px;
  right: 40px;
  padding: 10px 20px;
  background-color: #d5ca00;
  color: white;
  border: none;
  border-radius: 5px;
  z-index: 1;
  cursor: pointer;
}

.recalculate-btn:hover {
  background-color: #7ee35c;
}

.result-box {
  margin-top: 10px;
  padding: 5px 10px;
  background-color: #092038;
  // border: 1px solid #ccc;
  border-radius: 5px;
  text-align: center;
  font-size: 14px;
  color: #FFFFFF;
}

</style>
